home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Doc / libppath.tex < prev    next >
LaTeX Document  |  1994-04-21  |  4.7 KB  |  [TEXT/R*ch]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: LaTeX Document (document/latex).

You can browse this item here: libppath.tex

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text, with CR line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CR] default (weak)


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[R*ch]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 53 74 61 6e 64 61 72 |\section|{Standar|
|00000010| 64 20 4d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |d Module| \sectco|
|00000020| 64 65 7b 70 6f 73 69 78 | 70 61 74 68 7d 7d 0d 0d |de{posix|path}}..|
|00000030| 5c 73 74 6d 6f 64 69 6e | 64 65 78 7b 70 6f 73 69 |\stmodin|dex{posi|
|00000040| 78 70 61 74 68 7d 0d 54 | 68 69 73 20 6d 6f 64 75 |xpath}.T|his modu|
|00000050| 6c 65 20 69 6d 70 6c 65 | 6d 65 6e 74 73 20 73 6f |le imple|ments so|
|00000060| 6d 65 20 75 73 65 66 75 | 6c 20 66 75 6e 63 74 69 |me usefu|l functi|
|00000070| 6f 6e 73 20 6f 6e 20 50 | 4f 53 49 58 20 70 61 74 |ons on P|OSIX pat|
|00000080| 68 6e 61 6d 65 73 2e 0d | 0d 5c 72 65 6e 65 77 63 |hnames..|.\renewc|
|00000090| 6f 6d 6d 61 6e 64 7b 5c | 69 6e 64 65 78 73 75 62 |ommand{\|indexsub|
|000000a0| 69 74 65 6d 7d 7b 28 69 | 6e 20 6d 6f 64 75 6c 65 |item}{(i|n module|
|000000b0| 20 70 6f 73 69 78 70 61 | 74 68 29 7d 0d 5c 62 65 | posixpa|th)}.\be|
|000000c0| 67 69 6e 7b 66 75 6e 63 | 64 65 73 63 7d 7b 62 61 |gin{func|desc}{ba|
|000000d0| 73 65 6e 61 6d 65 7d 7b | 70 7d 0d 52 65 74 75 72 |sename}{|p}.Retur|
|000000e0| 6e 20 74 68 65 20 62 61 | 73 65 20 6e 61 6d 65 20 |n the ba|se name |
|000000f0| 6f 66 20 70 61 74 68 6e | 61 6d 65 0d 5c 76 61 72 |of pathn|ame.\var|
|00000100| 7b 70 7d 2e 0d 54 68 69 | 73 20 69 73 20 74 68 65 |{p}..Thi|s is the|
|00000110| 20 73 65 63 6f 6e 64 20 | 68 61 6c 66 20 6f 66 20 | second |half of |
|00000120| 74 68 65 20 70 61 69 72 | 20 72 65 74 75 72 6e 65 |the pair| returne|
|00000130| 64 20 62 79 0d 5c 63 6f | 64 65 7b 70 6f 73 69 78 |d by.\co|de{posix|
|00000140| 70 61 74 68 2e 73 70 6c | 69 74 28 5c 76 61 72 7b |path.spl|it(\var{|
|00000150| 70 7d 29 7d 2e 0d 5c 65 | 6e 64 7b 66 75 6e 63 64 |p})}..\e|nd{funcd|
|00000160| 65 73 63 7d 0d 0d 5c 62 | 65 67 69 6e 7b 66 75 6e |esc}..\b|egin{fun|
|00000170| 63 64 65 73 63 7d 7b 63 | 6f 6d 6d 6f 6e 70 72 65 |cdesc}{c|ommonpre|
|00000180| 66 69 78 7d 7b 6c 69 73 | 74 7d 0d 52 65 74 75 72 |fix}{lis|t}.Retur|
|00000190| 6e 20 74 68 65 20 6c 6f | 6e 67 65 73 74 20 73 74 |n the lo|ngest st|
|000001a0| 72 69 6e 67 20 74 68 61 | 74 20 69 73 20 61 20 70 |ring tha|t is a p|
|000001b0| 72 65 66 69 78 20 6f 66 | 20 61 6c 6c 20 73 74 72 |refix of| all str|
|000001c0| 69 6e 67 73 20 69 6e 0d | 5c 76 61 72 7b 6c 69 73 |ings in.|\var{lis|
|000001d0| 74 7d 2e 0d 49 66 0d 5c | 76 61 72 7b 6c 69 73 74 |t}..If.\|var{list|
|000001e0| 7d 0d 69 73 20 65 6d 70 | 74 79 2c 20 72 65 74 75 |}.is emp|ty, retu|
|000001f0| 72 6e 20 74 68 65 20 65 | 6d 70 74 79 20 73 74 72 |rn the e|mpty str|
|00000200| 69 6e 67 20 28 5c 63 6f | 64 65 7b 27 27 7d 29 2e |ing (\co|de{''}).|
|00000210| 0d 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0d |.\end{fu|ncdesc}.|
|00000220| 0d 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|00000230| 7d 7b 65 78 69 73 74 73 | 7d 7b 70 7d 0d 52 65 74 |}{exists|}{p}.Ret|
|00000240| 75 72 6e 20 74 72 75 65 | 20 69 66 0d 5c 76 61 72 |urn true| if.\var|
|00000250| 7b 70 7d 0d 72 65 66 65 | 72 73 20 74 6f 20 61 6e |{p}.refe|rs to an|
|00000260| 20 65 78 69 73 74 69 6e | 67 20 70 61 74 68 2e 0d | existin|g path..|
|00000270| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0d 0d |\end{fun|cdesc}..|
|00000280| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|00000290| 7b 65 78 70 61 6e 64 75 | 73 65 72 7d 7b 70 7d 0d |{expandu|ser}{p}.|
|000002a0| 52 65 74 75 72 6e 20 74 | 68 65 20 61 72 67 75 6d |Return t|he argum|
|000002b0| 65 6e 74 20 77 69 74 68 | 20 61 6e 20 69 6e 69 74 |ent with| an init|
|000002c0| 69 61 6c 20 63 6f 6d 70 | 6f 6e 65 6e 74 20 6f 66 |ial comp|onent of|
|000002d0| 20 5c 73 61 6d 70 7b 5c | 7e 7d 20 6f 72 0d 5c 73 | \samp{\|~} or.\s|
|000002e0| 61 6d 70 7b 5c 7e 5c 76 | 61 72 7b 75 73 65 72 7d |amp{\~\v|ar{user}|
|000002f0| 7d 20 72 65 70 6c 61 63 | 65 64 20 62 79 20 74 68 |} replac|ed by th|
|00000300| 61 74 20 5c 76 61 72 7b | 75 73 65 72 7d 27 73 20 |at \var{|user}'s |
|00000310| 68 6f 6d 65 20 64 69 72 | 65 63 74 6f 72 79 2e 20 |home dir|ectory. |
|00000320| 20 41 6e 0d 69 6e 69 74 | 69 61 6c 20 5c 73 61 6d | An.init|ial \sam|
|00000330| 70 7b 5c 7e 7b 7d 7d 20 | 69 73 20 72 65 70 6c 61 |p{\~{}} |is repla|
|00000340| 63 65 64 20 62 79 20 74 | 68 65 20 65 6e 76 69 72 |ced by t|he envir|
|00000350| 6f 6e 6d 65 6e 74 20 76 | 61 72 69 61 62 6c 65 20 |onment v|ariable |
|00000360| 5c 63 6f 64 65 7b 5c 24 | 7b 7d 48 4f 4d 45 7d 3b |\code{\$|{}HOME};|
|00000370| 0d 61 6e 20 69 6e 69 74 | 69 61 6c 20 5c 73 61 6d |.an init|ial \sam|
|00000380| 70 7b 5c 7e 5c 76 61 72 | 7b 75 73 65 72 7d 7d 20 |p{\~\var|{user}} |
|00000390| 69 73 20 6c 6f 6f 6b 65 | 64 20 75 70 20 69 6e 20 |is looke|d up in |
|000003a0| 74 68 65 20 70 61 73 73 | 77 6f 72 64 20 64 69 72 |the pass|word dir|
|000003b0| 65 63 74 6f 72 79 20 74 | 68 72 6f 75 67 68 0d 74 |ectory t|hrough.t|
|000003c0| 68 65 20 62 75 69 6c 74 | 2d 69 6e 20 6d 6f 64 75 |he built|-in modu|
|000003d0| 6c 65 20 5c 63 6f 64 65 | 7b 70 77 64 7d 2e 20 20 |le \code|{pwd}. |
|000003e0| 49 66 20 74 68 65 20 65 | 78 70 61 6e 73 69 6f 6e |If the e|xpansion|
|000003f0| 20 66 61 69 6c 73 2c 20 | 6f 72 20 69 66 20 74 68 | fails, |or if th|
|00000400| 65 0d 70 61 74 68 20 64 | 6f 65 73 20 6e 6f 74 20 |e.path d|oes not |
|00000410| 62 65 67 69 6e 20 77 69 | 74 68 20 61 20 74 69 6c |begin wi|th a til|
|00000420| 64 65 2c 20 74 68 65 20 | 70 61 74 68 20 69 73 20 |de, the |path is |
|00000430| 72 65 74 75 72 6e 65 64 | 20 75 6e 63 68 61 6e 67 |returned| unchang|
|00000440| 65 64 2e 0d 5c 65 6e 64 | 7b 66 75 6e 63 64 65 73 |ed..\end|{funcdes|
|00000450| 63 7d 0d 0d 5c 62 65 67 | 69 6e 7b 66 75 6e 63 64 |c}..\beg|in{funcd|
|00000460| 65 73 63 7d 7b 65 78 70 | 61 6e 64 76 61 72 73 7d |esc}{exp|andvars}|
|00000470| 7b 70 7d 0d 52 65 74 75 | 72 6e 20 74 68 65 20 61 |{p}.Retu|rn the a|
|00000480| 72 67 75 6d 65 6e 74 20 | 77 69 74 68 20 65 6e 76 |rgument |with env|
|00000490| 69 72 6f 6e 6d 65 6e 74 | 20 76 61 72 69 61 62 6c |ironment| variabl|
|000004a0| 65 73 20 65 78 70 61 6e | 64 65 64 2e 20 20 53 75 |es expan|ded. Su|
|000004b0| 62 73 74 72 69 6e 67 73 | 0d 6f 66 20 74 68 65 20 |bstrings|.of the |
|000004c0| 66 6f 72 6d 20 5c 73 61 | 6d 70 7b 5c 24 5c 76 61 |form \sa|mp{\$\va|
|000004d0| 72 7b 6e 61 6d 65 7d 7d | 20 6f 72 20 5c 73 61 6d |r{name}}| or \sam|
|000004e0| 70 7b 5c 24 5c 7b 5c 76 | 61 72 7b 6e 61 6d 65 7d |p{\$\{\v|ar{name}|
|000004f0| 5c 7d 7d 20 61 72 65 0d | 72 65 70 6c 61 63 65 64 |\}} are.|replaced|
|00000500| 20 62 79 20 74 68 65 20 | 76 61 6c 75 65 20 6f 66 | by the |value of|
|00000510| 20 65 6e 76 69 72 6f 6e | 6d 65 6e 74 20 76 61 72 | environ|ment var|
|00000520| 69 61 62 6c 65 20 5c 76 | 61 72 7b 6e 61 6d 65 7d |iable \v|ar{name}|
|00000530| 2e 20 20 4d 61 6c 66 6f | 72 6d 65 64 0d 76 61 72 |. Malfo|rmed.var|
|00000540| 69 61 62 6c 65 20 6e 61 | 6d 65 73 20 61 6e 64 20 |iable na|mes and |
|00000550| 72 65 66 65 72 65 6e 63 | 65 73 20 74 6f 20 6e 6f |referenc|es to no|
|00000560| 6e 2d 65 78 69 73 74 69 | 6e 67 20 76 61 72 69 61 |n-existi|ng varia|
|00000570| 62 6c 65 73 20 61 72 65 | 20 6c 65 66 74 0d 75 6e |bles are| left.un|
|00000580| 63 68 61 6e 67 65 64 2e | 0d 5c 65 6e 64 7b 66 75 |changed.|.\end{fu|
|00000590| 6e 63 64 65 73 63 7d 0d | 0d 5c 62 65 67 69 6e 7b |ncdesc}.|.\begin{|
|000005a0| 66 75 6e 63 64 65 73 63 | 7d 7b 69 73 61 62 73 7d |funcdesc|}{isabs}|
|000005b0| 7b 70 7d 0d 52 65 74 75 | 72 6e 20 74 72 75 65 20 |{p}.Retu|rn true |
|000005c0| 69 66 20 5c 76 61 72 7b | 70 7d 20 69 73 20 61 6e |if \var{|p} is an|
|000005d0| 20 61 62 73 6f 6c 75 74 | 65 20 70 61 74 68 6e 61 | absolut|e pathna|
|000005e0| 6d 65 20 28 62 65 67 69 | 6e 73 20 77 69 74 68 20 |me (begi|ns with |
|000005f0| 61 20 73 6c 61 73 68 29 | 2e 0d 5c 65 6e 64 7b 66 |a slash)|..\end{f|
|00000600| 75 6e 63 64 65 73 63 7d | 0d 0d 5c 62 65 67 69 6e |uncdesc}|..\begin|
|00000610| 7b 66 75 6e 63 64 65 73 | 63 7d 7b 69 73 66 69 6c |{funcdes|c}{isfil|
|00000620| 65 7d 7b 70 7d 0d 52 65 | 74 75 72 6e 20 74 72 75 |e}{p}.Re|turn tru|
|00000630| 65 20 69 66 20 5c 76 61 | 72 7b 70 7d 20 69 73 20 |e if \va|r{p} is |
|00000640| 61 6e 20 65 78 69 73 74 | 69 6e 67 20 72 65 67 75 |an exist|ing regu|
|00000650| 6c 61 72 20 66 69 6c 65 | 2e 20 20 54 68 69 73 20 |lar file|. This |
|00000660| 66 6f 6c 6c 6f 77 73 0d | 73 79 6d 62 6f 6c 69 63 |follows.|symbolic|
|00000670| 20 6c 69 6e 6b 73 2c 20 | 73 6f 20 62 6f 74 68 20 | links, |so both |
|00000680| 69 73 6c 69 6e 6b 28 29 | 20 61 6e 64 20 69 73 66 |islink()| and isf|
|00000690| 69 6c 65 28 29 20 63 61 | 6e 20 62 65 20 74 72 75 |ile() ca|n be tru|
|000006a0| 65 20 66 6f 72 20 74 68 | 65 20 73 61 6d 65 0d 70 |e for th|e same.p|
|000006b0| 61 74 68 2e 0d 5c 65 6e | 64 7b 66 75 6e 63 64 65 |ath..\en|d{funcde|
|000006c0| 73 63 7d 0d 0d 5c 62 65 | 67 69 6e 7b 66 75 6e 63 |sc}..\be|gin{func|
|000006d0| 64 65 73 63 7d 7b 69 73 | 64 69 72 7d 7b 70 7d 0d |desc}{is|dir}{p}.|
|000006e0| 52 65 74 75 72 6e 20 74 | 72 75 65 20 69 66 20 5c |Return t|rue if \|
|000006f0| 76 61 72 7b 70 7d 20 69 | 73 20 61 6e 20 65 78 69 |var{p} i|s an exi|
|00000700| 73 74 69 6e 67 20 64 69 | 72 65 63 74 6f 72 79 2e |sting di|rectory.|
|00000710| 20 20 54 68 69 73 20 66 | 6f 6c 6c 6f 77 73 0d 73 | This f|ollows.s|
|00000720| 79 6d 62 6f 6c 69 63 20 | 6c 69 6e 6b 73 2c 20 73 |ymbolic |links, s|
|00000730| 6f 20 62 6f 74 68 20 69 | 73 6c 69 6e 6b 28 29 20 |o both i|slink() |
|00000740| 61 6e 64 20 69 73 64 69 | 72 28 29 20 63 61 6e 20 |and isdi|r() can |
|00000750| 62 65 20 74 72 75 65 20 | 66 6f 72 20 74 68 65 20 |be true |for the |
|00000760| 73 61 6d 65 0d 70 61 74 | 68 2e 0d 5c 65 6e 64 7b |same.pat|h..\end{|
|00000770| 66 75 6e 63 64 65 73 63 | 7d 0d 0d 5c 62 65 67 69 |funcdesc|}..\begi|
|00000780| 6e 7b 66 75 6e 63 64 65 | 73 63 7d 7b 69 73 6c 69 |n{funcde|sc}{isli|
|00000790| 6e 6b 7d 7b 70 7d 0d 52 | 65 74 75 72 6e 20 74 72 |nk}{p}.R|eturn tr|
|000007a0| 75 65 20 69 66 0d 5c 76 | 61 72 7b 70 7d 0d 72 65 |ue if.\v|ar{p}.re|
|000007b0| 66 65 72 73 20 74 6f 20 | 61 20 64 69 72 65 63 74 |fers to |a direct|
|000007c0| 6f 72 79 20 65 6e 74 72 | 79 20 74 68 61 74 20 69 |ory entr|y that i|
|000007d0| 73 20 61 20 73 79 6d 62 | 6f 6c 69 63 20 6c 69 6e |s a symb|olic lin|
|000007e0| 6b 2e 0d 41 6c 77 61 79 | 73 20 66 61 6c 73 65 20 |k..Alway|s false |
|000007f0| 69 66 20 73 79 6d 62 6f | 6c 69 63 20 6c 69 6e 6b |if symbo|lic link|
|00000800| 73 20 61 72 65 20 6e 6f | 74 20 73 75 70 70 6f 72 |s are no|t suppor|
|00000810| 74 65 64 2e 0d 5c 65 6e | 64 7b 66 75 6e 63 64 65 |ted..\en|d{funcde|
|00000820| 73 63 7d 0d 0d 5c 62 65 | 67 69 6e 7b 66 75 6e 63 |sc}..\be|gin{func|
|00000830| 64 65 73 63 7d 7b 69 73 | 6d 6f 75 6e 74 7d 7b 70 |desc}{is|mount}{p|
|00000840| 7d 0d 52 65 74 75 72 6e | 20 74 72 75 65 20 69 66 |}.Return| true if|
|00000850| 20 5c 76 61 72 7b 70 7d | 20 69 73 20 61 20 6d 6f | \var{p}| is a mo|
|00000860| 75 6e 74 20 70 6f 69 6e | 74 2e 20 20 28 54 68 69 |unt poin|t. (Thi|
|00000870| 73 20 63 75 72 72 65 6e | 74 6c 79 20 63 68 65 63 |s curren|tly chec|
|00000880| 6b 73 20 77 68 65 74 68 | 65 72 0d 5c 63 6f 64 65 |ks wheth|er.\code|
|00000890| 7b 5c 76 61 72 7b 70 7d | 2f 2e 2e 7d 20 69 73 20 |{\var{p}|/..} is |
|000008a0| 6f 6e 20 61 20 64 69 66 | 66 65 72 65 6e 74 20 64 |on a dif|ferent d|
|000008b0| 65 76 69 63 65 20 66 72 | 6f 6d 20 5c 76 61 72 7b |evice fr|om \var{|
|000008c0| 70 7d 20 6f 72 20 77 68 | 65 74 68 65 72 0d 5c 63 |p} or wh|ether.\c|
|000008d0| 6f 64 65 7b 5c 76 61 72 | 7b 70 7d 2f 2e 2e 7d 20 |ode{\var|{p}/..} |
|000008e0| 61 6e 64 20 5c 76 61 72 | 7b 70 7d 20 70 6f 69 6e |and \var|{p} poin|
|000008f0| 74 20 74 6f 20 74 68 65 | 20 73 61 6d 65 20 69 2d |t to the| same i-|
|00000900| 6e 6f 64 65 20 6f 6e 20 | 74 68 65 20 73 61 6d 65 |node on |the same|
|00000910| 0d 64 65 76 69 63 65 20 | 2d 2d 2d 20 69 73 20 74 |.device |--- is t|
|00000920| 68 69 73 20 74 65 73 74 | 20 63 6f 72 72 65 63 74 |his test| correct|
|00000930| 20 66 6f 72 20 61 6c 6c | 20 5c 55 4e 49 58 7b 7d | for all| \UNIX{}|
|00000940| 20 61 6e 64 20 50 4f 53 | 49 58 20 76 61 72 69 61 | and POS|IX varia|
|00000950| 6e 74 73 3f 29 0d 5c 65 | 6e 64 7b 66 75 6e 63 64 |nts?).\e|nd{funcd|
|00000960| 65 73 63 7d 0d 0d 5c 62 | 65 67 69 6e 7b 66 75 6e |esc}..\b|egin{fun|
|00000970| 63 64 65 73 63 7d 7b 6a | 6f 69 6e 7d 7b 70 5c 2c |cdesc}{j|oin}{p\,|
|00000980| 20 71 7d 0d 4a 6f 69 6e | 20 74 68 65 20 70 61 74 | q}.Join| the pat|
|00000990| 68 73 0d 5c 76 61 72 7b | 70 7d 0d 61 6e 64 0d 5c |hs.\var{|p}.and.\|
|000009a0| 76 61 72 7b 71 7d 20 69 | 6e 74 65 6c 6c 69 67 65 |var{q} i|ntellige|
|000009b0| 6e 74 6c 79 3a 0d 49 66 | 0d 5c 76 61 72 7b 71 7d |ntly:.If|.\var{q}|
|000009c0| 0d 69 73 20 61 6e 20 61 | 62 73 6f 6c 75 74 65 20 |.is an a|bsolute |
|000009d0| 70 61 74 68 2c 20 74 68 | 65 20 72 65 74 75 72 6e |path, th|e return|
|000009e0| 20 76 61 6c 75 65 20 69 | 73 0d 5c 76 61 72 7b 71 | value i|s.\var{q|
|000009f0| 7d 2e 0d 4f 74 68 65 72 | 77 69 73 65 2c 20 74 68 |}..Other|wise, th|
|00000a00| 65 20 63 6f 6e 63 61 74 | 65 6e 61 74 69 6f 6e 20 |e concat|enation |
|00000a10| 6f 66 0d 5c 76 61 72 7b | 70 7d 0d 61 6e 64 0d 5c |of.\var{|p}.and.\|
|00000a20| 76 61 72 7b 71 7d 0d 69 | 73 20 72 65 74 75 72 6e |var{q}.i|s return|
|00000a30| 65 64 2c 20 77 69 74 68 | 20 61 20 73 6c 61 73 68 |ed, with| a slash|
|00000a40| 20 28 5c 63 6f 64 65 7b | 27 2f 27 7d 29 20 69 6e | (\code{|'/'}) in|
|00000a50| 73 65 72 74 65 64 20 75 | 6e 6c 65 73 73 0d 5c 76 |serted u|nless.\v|
|00000a60| 61 72 7b 70 7d 0d 69 73 | 20 65 6d 70 74 79 20 6f |ar{p}.is| empty o|
|00000a70| 72 20 65 6e 64 73 20 69 | 6e 20 61 20 73 6c 61 73 |r ends i|n a slas|
|00000a80| 68 2e 0d 5c 65 6e 64 7b | 66 75 6e 63 64 65 73 63 |h..\end{|funcdesc|
|00000a90| 7d 0d 0d 5c 62 65 67 69 | 6e 7b 66 75 6e 63 64 65 |}..\begi|n{funcde|
|00000aa0| 73 63 7d 7b 6e 6f 72 6d | 63 61 73 65 7d 7b 70 7d |sc}{norm|case}{p}|
|00000ab0| 0d 4e 6f 72 6d 61 6c 69 | 7a 65 20 74 68 65 20 63 |.Normali|ze the c|
|00000ac0| 61 73 65 20 6f 66 20 61 | 20 70 61 74 68 6e 61 6d |ase of a| pathnam|
|00000ad0| 65 2e 20 20 54 68 69 73 | 20 72 65 74 75 72 6e 73 |e. This| returns|
|00000ae0| 20 74 68 65 20 70 61 74 | 68 20 75 6e 63 68 61 6e | the pat|h unchan|
|00000af0| 67 65 64 3b 0d 68 6f 77 | 65 76 65 72 2c 20 61 20 |ged;.how|ever, a |
|00000b00| 73 69 6d 69 6c 61 72 20 | 66 75 6e 63 74 69 6f 6e |similar |function|
|00000b10| 20 69 6e 20 5c 63 6f 64 | 65 7b 6d 61 63 70 61 74 | in \cod|e{macpat|
|00000b20| 68 7d 20 63 6f 6e 76 65 | 72 74 73 20 75 70 70 65 |h} conve|rts uppe|
|00000b30| 72 20 63 61 73 65 20 74 | 6f 0d 6c 6f 77 65 72 20 |r case t|o.lower |
|00000b40| 63 61 73 65 2e 0d 5c 65 | 6e 64 7b 66 75 6e 63 64 |case..\e|nd{funcd|
|00000b50| 65 73 63 7d 0d 0d 5c 62 | 65 67 69 6e 7b 66 75 6e |esc}..\b|egin{fun|
|00000b60| 63 64 65 73 63 7d 7b 73 | 61 6d 65 66 69 6c 65 7d |cdesc}{s|amefile}|
|00000b70| 7b 70 5c 2c 20 71 7d 0d | 52 65 74 75 72 6e 20 74 |{p\, q}.|Return t|
|00000b80| 72 75 65 20 69 66 20 62 | 6f 74 68 20 70 61 74 68 |rue if b|oth path|
|00000b90| 6e 61 6d 65 20 61 72 67 | 75 6d 65 6e 74 73 20 72 |name arg|uments r|
|00000ba0| 65 66 65 72 20 74 6f 20 | 74 68 65 20 73 61 6d 65 |efer to |the same|
|00000bb0| 20 66 69 6c 65 20 6f 72 | 20 64 69 72 65 63 74 6f | file or| directo|
|00000bc0| 72 79 0d 28 61 73 20 69 | 6e 64 69 63 61 74 65 64 |ry.(as i|ndicated|
|00000bd0| 20 62 79 20 64 65 76 69 | 63 65 20 6e 75 6d 62 65 | by devi|ce numbe|
|00000be0| 72 20 61 6e 64 20 69 2d | 6e 6f 64 65 20 6e 75 6d |r and i-|node num|
|00000bf0| 62 65 72 29 2e 0d 52 61 | 69 73 65 20 61 6e 20 65 |ber)..Ra|ise an e|
|00000c00| 78 63 65 70 74 69 6f 6e | 20 69 66 20 61 20 73 74 |xception| if a st|
|00000c10| 61 74 20 63 61 6c 6c 20 | 6f 6e 20 65 69 74 68 65 |at call |on eithe|
|00000c20| 72 20 70 61 74 68 6e 61 | 6d 65 20 66 61 69 6c 73 |r pathna|me fails|
|00000c30| 2e 0d 5c 65 6e 64 7b 66 | 75 6e 63 64 65 73 63 7d |..\end{f|uncdesc}|
|00000c40| 0d 0d 5c 62 65 67 69 6e | 7b 66 75 6e 63 64 65 73 |..\begin|{funcdes|
|00000c50| 63 7d 7b 73 70 6c 69 74 | 7d 7b 70 7d 0d 53 70 6c |c}{split|}{p}.Spl|
|00000c60| 69 74 20 74 68 65 20 70 | 61 74 68 6e 61 6d 65 20 |it the p|athname |
|00000c70| 5c 76 61 72 7b 70 7d 20 | 69 6e 20 61 20 70 61 69 |\var{p} |in a pai|
|00000c80| 72 20 5c 63 6f 64 65 7b | 28 5c 76 61 72 7b 68 65 |r \code{|(\var{he|
|00000c90| 61 64 7d 2c 20 5c 76 61 | 72 7b 74 61 69 6c 7d 29 |ad}, \va|r{tail})|
|00000ca0| 7d 2c 20 77 68 65 72 65 | 0d 5c 76 61 72 7b 74 61 |}, where|.\var{ta|
|00000cb0| 69 6c 7d 20 69 73 20 74 | 68 65 20 6c 61 73 74 20 |il} is t|he last |
|00000cc0| 70 61 74 68 6e 61 6d 65 | 20 63 6f 6d 70 6f 6e 65 |pathname| compone|
|00000cd0| 6e 74 20 61 6e 64 20 5c | 76 61 72 7b 68 65 61 64 |nt and \|var{head|
|00000ce0| 7d 20 69 73 0d 65 76 65 | 72 79 74 68 69 6e 67 20 |} is.eve|rything |
|00000cf0| 6c 65 61 64 69 6e 67 20 | 75 70 20 74 6f 20 74 68 |leading |up to th|
|00000d00| 61 74 2e 20 20 49 66 20 | 5c 76 61 72 7b 70 7d 20 |at. If |\var{p} |
|00000d10| 65 6e 64 73 20 69 6e 20 | 61 20 73 6c 61 73 68 20 |ends in |a slash |
|00000d20| 28 65 78 63 65 70 74 20 | 69 66 0d 69 74 20 69 73 |(except |if.it is|
|00000d30| 20 74 68 65 20 72 6f 6f | 74 29 2c 20 74 68 65 20 | the roo|t), the |
|00000d40| 74 72 61 69 6c 69 6e 67 | 20 73 6c 61 73 68 20 69 |trailing| slash i|
|00000d50| 73 20 72 65 6d 6f 76 65 | 64 20 61 6e 64 20 74 68 |s remove|d and th|
|00000d60| 65 20 6f 70 65 72 61 74 | 69 6f 6e 0d 61 70 70 6c |e operat|ion.appl|
|00000d70| 69 65 64 20 74 6f 20 74 | 68 65 20 72 65 73 75 6c |ied to t|he resul|
|00000d80| 74 3b 20 6f 74 68 65 72 | 77 69 73 65 2c 20 5c 63 |t; other|wise, \c|
|00000d90| 6f 64 65 7b 6a 6f 69 6e | 28 5c 76 61 72 7b 68 65 |ode{join|(\var{he|
|00000da0| 61 64 7d 2c 20 5c 76 61 | 72 7b 74 61 69 6c 7d 29 |ad}, \va|r{tail})|
|00000db0| 7d 20 65 71 75 61 6c 73 | 0d 5c 76 61 72 7b 70 7d |} equals|.\var{p}|
|00000dc0| 2e 20 20 54 68 65 20 5c | 76 61 72 7b 74 61 69 6c |. The \|var{tail|
|00000dd0| 7d 20 70 61 72 74 20 6e | 65 76 65 72 20 63 6f 6e |} part n|ever con|
|00000de0| 74 61 69 6e 73 20 61 20 | 73 6c 61 73 68 2e 20 20 |tains a |slash. |
|00000df0| 53 6f 6d 65 20 62 6f 75 | 6e 64 61 72 79 0d 63 61 |Some bou|ndary.ca|
|00000e00| 73 65 73 3a 20 69 66 20 | 5c 76 61 72 7b 70 7d 20 |ses: if |\var{p} |
|00000e10| 69 73 20 74 68 65 20 72 | 6f 6f 74 2c 20 5c 76 61 |is the r|oot, \va|
|00000e20| 72 7b 68 65 61 64 7d 20 | 65 71 75 61 6c 73 20 5c |r{head} |equals \|
|00000e30| 76 61 72 7b 70 7d 20 61 | 6e 64 0d 5c 76 61 72 7b |var{p} a|nd.\var{|
|00000e40| 74 61 69 6c 7d 20 69 73 | 20 65 6d 70 74 79 3b 20 |tail} is| empty; |
|00000e50| 69 66 20 5c 76 61 72 7b | 70 7d 20 69 73 20 65 6d |if \var{|p} is em|
|00000e60| 70 74 79 2c 20 62 6f 74 | 68 20 5c 76 61 72 7b 68 |pty, bot|h \var{h|
|00000e70| 65 61 64 7d 20 61 6e 64 | 0d 5c 76 61 72 7b 74 61 |ead} and|.\var{ta|
|00000e80| 69 6c 7d 20 61 72 65 20 | 65 6d 70 74 79 3b 20 69 |il} are |empty; i|
|00000e90| 66 20 5c 76 61 72 7b 70 | 7d 20 63 6f 6e 74 61 69 |f \var{p|} contai|
|00000ea0| 6e 73 20 6e 6f 20 73 6c | 61 73 68 2c 20 5c 76 61 |ns no sl|ash, \va|
|00000eb0| 72 7b 68 65 61 64 7d 20 | 69 73 0d 65 6d 70 74 79 |r{head} |is.empty|
|00000ec0| 20 61 6e 64 20 5c 76 61 | 72 7b 74 61 69 6c 7d 20 | and \va|r{tail} |
|00000ed0| 65 71 75 61 6c 73 20 5c | 76 61 72 7b 70 7d 2e 0d |equals \|var{p}..|
|00000ee0| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0d 0d |\end{fun|cdesc}..|
|00000ef0| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|00000f00| 7b 73 70 6c 69 74 65 78 | 74 7d 7b 70 7d 0d 53 70 |{splitex|t}{p}.Sp|
|00000f10| 6c 69 74 20 74 68 65 20 | 70 61 74 68 6e 61 6d 65 |lit the |pathname|
|00000f20| 20 5c 76 61 72 7b 70 7d | 20 69 6e 20 61 20 70 61 | \var{p}| in a pa|
|00000f30| 69 72 20 5c 63 6f 64 65 | 7b 28 5c 76 61 72 7b 72 |ir \code|{(\var{r|
|00000f40| 6f 6f 74 7d 2c 20 5c 76 | 61 72 7b 65 78 74 7d 29 |oot}, \v|ar{ext})|
|00000f50| 7d 0d 73 75 63 68 20 74 | 68 61 74 20 5c 63 6f 64 |}.such t|hat \cod|
|00000f60| 65 7b 5c 76 61 72 7b 72 | 6f 6f 74 7d 20 2b 20 5c |e{\var{r|oot} + \|
|00000f70| 76 61 72 7b 65 78 74 7d | 20 3d 3d 20 5c 76 61 72 |var{ext}| == \var|
|00000f80| 7b 70 7d 7d 2c 0d 74 68 | 65 20 6c 61 73 74 20 63 |{p}},.th|e last c|
|00000f90| 6f 6d 70 6f 6e 65 6e 74 | 20 6f 66 20 5c 76 61 72 |omponent| of \var|
|00000fa0| 7b 72 6f 6f 74 7d 20 63 | 6f 6e 74 61 69 6e 73 20 |{root} c|ontains |
|00000fb0| 6e 6f 20 70 65 72 69 6f | 64 73 2c 0d 61 6e 64 20 |no perio|ds,.and |
|00000fc0| 5c 76 61 72 7b 65 78 74 | 7d 20 69 73 20 65 6d 70 |\var{ext|} is emp|
|00000fd0| 74 79 20 6f 72 20 62 65 | 67 69 6e 73 20 77 69 74 |ty or be|gins wit|
|00000fe0| 68 20 61 20 70 65 72 69 | 6f 64 2e 0d 5c 65 6e 64 |h a peri|od..\end|
|00000ff0| 7b 66 75 6e 63 64 65 73 | 63 7d 0d 0d 5c 62 65 67 |{funcdes|c}..\beg|
|00001000| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 77 61 6c |in{funcd|esc}{wal|
|00001010| 6b 7d 7b 70 5c 2c 20 76 | 69 73 69 74 5c 2c 20 61 |k}{p\, v|isit\, a|
|00001020| 72 67 7d 0d 43 61 6c 6c | 73 20 74 68 65 20 66 75 |rg}.Call|s the fu|
|00001030| 6e 63 74 69 6f 6e 20 5c | 76 61 72 7b 76 69 73 69 |nction \|var{visi|
|00001040| 74 7d 20 77 69 74 68 20 | 61 72 67 75 6d 65 6e 74 |t} with |argument|
|00001050| 73 0d 5c 63 6f 64 65 7b | 28 5c 76 61 72 7b 61 72 |s.\code{|(\var{ar|
|00001060| 67 7d 2c 20 5c 76 61 72 | 7b 64 69 72 6e 61 6d 65 |g}, \var|{dirname|
|00001070| 7d 2c 20 5c 76 61 72 7b | 6e 61 6d 65 73 7d 29 7d |}, \var{|names})}|
|00001080| 20 66 6f 72 20 65 61 63 | 68 20 64 69 72 65 63 74 | for eac|h direct|
|00001090| 6f 72 79 20 69 6e 20 74 | 68 65 0d 64 69 72 65 63 |ory in t|he.direc|
|000010a0| 74 6f 72 79 20 74 72 65 | 65 20 72 6f 6f 74 65 64 |tory tre|e rooted|
|000010b0| 20 61 74 20 5c 76 61 72 | 7b 70 7d 20 28 69 6e 63 | at \var|{p} (inc|
|000010c0| 6c 75 64 69 6e 67 20 5c | 76 61 72 7b 70 7d 20 69 |luding \|var{p} i|
|000010d0| 74 73 65 6c 66 2c 20 69 | 66 20 69 74 20 69 73 20 |tself, i|f it is |
|000010e0| 61 0d 64 69 72 65 63 74 | 6f 72 79 29 2e 20 20 54 |a.direct|ory). T|
|000010f0| 68 65 20 61 72 67 75 6d | 65 6e 74 20 5c 76 61 72 |he argum|ent \var|
|00001100| 7b 64 69 72 6e 61 6d 65 | 7d 20 73 70 65 63 69 66 |{dirname|} specif|
|00001110| 69 65 73 20 74 68 65 20 | 76 69 73 69 74 65 64 20 |ies the |visited |
|00001120| 64 69 72 65 63 74 6f 72 | 79 2c 0d 74 68 65 20 61 |director|y,.the a|
|00001130| 72 67 75 6d 65 6e 74 20 | 5c 76 61 72 7b 6e 61 6d |rgument |\var{nam|
|00001140| 65 73 7d 20 6c 69 73 74 | 73 20 74 68 65 20 66 69 |es} list|s the fi|
|00001150| 6c 65 73 20 69 6e 20 74 | 68 65 20 64 69 72 65 63 |les in t|he direc|
|00001160| 74 6f 72 79 20 28 67 6f | 74 74 65 6e 20 66 72 6f |tory (go|tten fro|
|00001170| 6d 0d 5c 63 6f 64 65 7b | 70 6f 73 69 78 2e 6c 69 |m.\code{|posix.li|
|00001180| 73 74 64 69 72 28 5c 76 | 61 72 7b 64 69 72 6e 61 |stdir(\v|ar{dirna|
|00001190| 6d 65 7d 29 7d 29 2e 20 | 20 54 68 65 20 5c 76 61 |me})}). | The \va|
|000011a0| 72 7b 76 69 73 69 74 7d | 20 66 75 6e 63 74 69 6f |r{visit}| functio|
|000011b0| 6e 20 6d 61 79 0d 6d 6f | 64 69 66 79 20 5c 76 61 |n may.mo|dify \va|
|000011c0| 72 7b 6e 61 6d 65 73 7d | 20 74 6f 20 69 6e 66 6c |r{names}| to infl|
|000011d0| 75 65 6e 63 65 20 74 68 | 65 20 73 65 74 20 6f 66 |uence th|e set of|
|000011e0| 20 64 69 72 65 63 74 6f | 72 69 65 73 20 76 69 73 | directo|ries vis|
|000011f0| 69 74 65 64 20 62 65 6c | 6f 77 0d 5c 76 61 72 7b |ited bel|ow.\var{|
|00001200| 64 69 72 6e 61 6d 65 7d | 2c 20 65 2e 67 2e 2c 20 |dirname}|, e.g., |
|00001210| 74 6f 20 61 76 6f 69 64 | 20 76 69 73 69 74 69 6e |to avoid| visitin|
|00001220| 67 20 63 65 72 74 61 69 | 6e 20 70 61 72 74 73 20 |g certai|n parts |
|00001230| 6f 66 20 74 68 65 20 74 | 72 65 65 2e 20 20 28 54 |of the t|ree. (T|
|00001240| 68 65 0d 6f 62 6a 65 63 | 74 20 72 65 66 65 72 72 |he.objec|t referr|
|00001250| 65 64 20 74 6f 20 62 79 | 20 5c 76 61 72 7b 6e 61 |ed to by| \var{na|
|00001260| 6d 65 73 7d 20 6d 75 73 | 74 20 62 65 20 6d 6f 64 |mes} mus|t be mod|
|00001270| 69 66 69 65 64 20 69 6e | 20 70 6c 61 63 65 2c 20 |ified in| place, |
|00001280| 75 73 69 6e 67 0d 5c 63 | 6f 64 65 7b 64 65 6c 7d |using.\c|ode{del}|
|00001290| 20 6f 72 20 73 6c 69 63 | 65 20 61 73 73 69 67 6e | or slic|e assign|
|000012a0| 6d 65 6e 74 2e 29 0d 5c | 65 6e 64 7b 66 75 6e 63 |ment.).\|end{func|
|000012b0| 64 65 73 63 7d 0d | |desc}. | |
+--------+-------------------------+-------------------------+--------+--------+